#include <vector>

using namespace std;

class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
        unordered_map<int, int> num_map;
        for (int i = 0; i < nums.size(); i++) {
            num_map[nums[i]] = i;
        }
        for (int i = 0; i < nums.size(); i++) {
            int num1 = target - nums[i];
            if (num_map.find(num1) != num_map.end()) {
                int num1_index = num_map[num1];
                if (num1_index != i) {
                    return {i, num1_index};
                }
            }
        }
        return {};
    }
};